package com.easydev.mq.rabbit.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * <Description> 简单消息接受，用于针对指定队列的接受(P2P模式)<br>
 * 
 * @author lx<br>
 * @version 1.0<br>
 * @CreateDate 2016年3月16日 <br>
 */
public abstract class RabbitQueueMessageListener extends RabbitMessageListener {
    private final static Logger LOGGER = LoggerFactory.getLogger(RabbitQueueMessageListener.class);

    public RabbitQueueMessageListener(String queueName) throws Exception {
        dealMessage(queueName, channelPool.borrowObject(""));
    }

    public RabbitQueueMessageListener(String queueName, String virtualHost) throws Exception {
        dealMessage(queueName, channelPool.borrowObject(virtualHost));
    }

    @Override
    public abstract void handleMessage(String message) throws Exception;

    @Override
    public void handleFailedMessage(String message) {
        LOGGER.error("deal message failed,message is " + message);
    }

}
